<template>
  <header class="header">
    <!--  -->
    <div class="header-top flex-align">
      <div class="header-db container flex-align">
        <nuxt-link to="" class="fz14 flex1 cfff">首页</nuxt-link>
        <p class="h-sj fz14">手机版</p>
        <div class="h-dbox">
          <div class="flex-align cursor-pointer">
            <p class="h-dh fz14">全站导航</p>
            <img class="h-dhimg" src="../assets/images/xs.png" alt="">
          </div>
          <!--  -->
          <div class="header-nav">
            <div class="header-na flex1">
              <div class="header-nat">网站导航</div>
              <ul>
                <li class="cursor-pointer" v-for="(item, index) in navList" :key="index">
                  <nuxt-link to="">{{ item.name }}</nuxt-link>
                </li>
              </ul>
            </div>
            <div class="header-na flex1">
              <div class="header-nat">热门专题</div>
              <ul>
                <li class="cursor-pointer" v-for="(item, index) in navList" :key="index">
                  <nuxt-link to="">{{ item.name }}</nuxt-link>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
      <!-- 全站导航 -->

    </div>
    <div class="header-con">
      <div class="header-con-t container flex-align flex-between">
        <img class="f-login" src="/assets/images/login.png" alt="">
        <!-- <div class="f-title flex1">
          <h1>羊托游</h1>
          <p>yangtuoyou.com</p>
        </div> -->
        <div class="f-r flex-column">
          <div class="f-rt flex-align">
            <input class="flex1" type="text" placeholder="搜索目的地/景点/主题">
            <img class="f-rb" src="../assets/images/search.png" alt="">
          </div>
          <ul class="f-ri flex-end mt10">
            <li v-for="(item, index) in recommendList" :key="index">
              <nuxt-link to="">{{ item.name }}</nuxt-link>
            </li>
          </ul>
        </div>
      </div>

      <div class="header-con-b container">
        <ul class="flex">
          <li :class="isClient && path == item.path ? 'on' : ''" v-for="(item, index) in menuList" :key="index">
            <nuxt-link @click="menuClick(item)" :to="item.path"><span>{{ item.name }}</span></nuxt-link>
          </li>
        </ul>
      </div>
    </div>
    <!--  -->
  </header>
</template>
<script setup>
const { $api, $used } = useNuxtApp()
const route = useRoute();
const isClient = ref(false);
const path = ref('/'); // 默认值设为 '/'

onMounted(() => {
  isClient.value = true;
  path.value = route.path;
})
//
//导航菜单
const websiteStore = useWebsiteStore();// 使用 store 实例
const { menuList } = storeToRefs(websiteStore);// 解构赋值并保持响应性
// 判断是否为空并调用接口
if (!menuList.value[0].id) {
  websiteStore.getMenu()
}
//点击菜单
const menuClick = (item) => {
  console.log(item.path, '---item.path');
  console.log(path.path, '---path.path');
  path.value = item.path;
}

//推荐游戏
const recommendList = ref([
  { name: '阴阳师', path: '/' },
  { name: '旅行青蛙', path: '/' },
  { name: '王者荣耀', path: '/' },
  { name: '蛋仔派对', path: '/' },
  { name: '阴阳师', path: '/' },
  { name: '阴阳师', path: '/' },
])
//全站导航
const navList = ref([
  { name: '手机导航', path: '/' },
  { name: '热门合集', path: '/mobile' },
  { name: '手机软件', path: '/nav' },
  { name: '游戏排行榜游戏排行榜', path: '/mobile' },
  { name: 'H5游戏', path: '/nav' },
  { name: '活动杂谈', path: '/mobile' },
  { name: '游戏攻略', path: '/nav' },
  { name: '软件教程', path: '/nav' },
])
</script>


<style lang="scss" scoped>
.header-top {
  height: 40px;
  background: #333333;
  color: #ffffff;

  .header-db {
    position: relative;
    height: 40px;

    .h-sj {
      padding-left: 18px;
      background: url('../assets/images/sj.png') no-repeat left center;
    }

    .h-dbox {
      position: relative;
      height: 40px;

      &:hover {
        .header-nav {
          display: block;
        }

        .h-dhimg {
          transform: rotate(180deg);
        }
      }

      .h-dhimg {
        width: 14px;
        height: 14px;
      }

      .h-dh {
        margin-left: 20px;
        padding-right: 5px;
        line-height: 40px;
      }

      .header-nav {
        display: none;
        position: absolute;
        top: 40px;
        right: 0;
        padding-right: 10px;
        z-index: 21;
        width: 446px;
        height: 228px;
        background: #FFFFFF;
        box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.25);
        border-radius: 10px;

        .header-na {
          display: inline-block;
          width: 50%;
          color: #333333;
          padding-top: 16px;

          .header-nat {
            text-align: center;
            line-height: 28px;
            font-weight: bold;
            font-size: 20px;
            color: #333333;
          }

          ul {
            margin-top: 10px;
            overflow: hidden;

            li {
              display: inline-block;
              white-space: nowrap;
              width: 50%;
              height: 41px;
              line-height: 41px;
              padding-left: 20px;
              font-size: 18px;

              &:first-child {
                color: #FF8E2B;
              }
            }
          }
        }
      }
    }

  }

}

.header-con {
  position: relative;
  height: 146px;
  background-color: #ffffff;

  .header-con-t {
    height: 90px;

    .f-login {
      margin-right: 10px;
      width: 181px;
      height: 60px;
    }

    .f-r {
      align-items: end;

      .f-rt {
        width: 300px;
        height: 36px;
        padding: 0 16px;
        background: #EBEBEB;
        border-radius: 30px;

        input {
          background: none;
          font-size: 14px;
          height: 36px;
          line-height: 36px;
          border: none;
        }

        .f-rb {
          margin-left: 10px;
          cursor: pointer;
        }
      }

      .f-ri {
        li {
          margin-left: 30px;
          font-size: 14px;
          color: #333333;
        }
      }
    }

    .f-title {
      h1 {
        font-weight: bold;
        line-height: 1.3;
        font-size: 32px;
        color: #333333;
      }

      p {
        font-weight: bold;
        font-size: 12px;
        color: #333333;
      }
    }
  }

  .header-con-b {
    height: 56px;
    color: #333333;

    ul {
      padding-left: 20px;

      li {
        position: relative;
        display: inline-block;
        margin-right: 75px;
        width: 100px;
        text-align: center;
        height: 56px;
        line-height: 56px;
        font-size: 20px;
        cursor: pointer;

        &.on {
          font-size: 26px;
          font-weight: bold;

          &:after {
            display: block;
          }
        }

        span {
          position: relative;
          z-index: 2;
        }

        &:hover {
          color: #ff0000;
        }

        &:after {
          display: none;
          content: '';
          position: absolute;
          left: 50%;
          top: 50%;
          margin-left: -35px;
          width: 70px;
          height: 14px;
          background: linear-gradient(90deg, rgba(255, 142, 43, 0.1) 0%, #FF8E2B 100%);
          border-radius: 10px;
          z-index: 1;
        }
      }
    }
  }
}
</style>